package com.lww.feature.test.proxy;

import java.lang.reflect.Proxy;

/**
 * User: yian
 * Date: 2017/5/20
 */
public class test {
    public static void main(String[] args) {
        RealSubject realSubject = new RealSubject();
        ProxyHandler handler = new ProxyHandler(realSubject);
        Subject proxySubject
                = (Subject) Proxy.newProxyInstance(
                        RealSubject.class.getClassLoader()
                ,RealSubject.class.getInterfaces(),handler);
        proxySubject.request();

        CglibProxy cglibProxy = new CglibProxy();
        RealSubjectCglib proxyInstance = (RealSubjectCglib)cglibProxy.getProxyInstance(new RealSubjectCglib());
        proxyInstance.request();//todo cglib动态代理还会报异常暂时无解

    }
}
